package cloud.demarcia.crawler3.utils;


public class ClockUtils{
    private final long time;

    public ClockUtils() {
        this.time = System.currentTimeMillis();
    }

    public String durationString(){
        int[] format=toTime();
        String timeString="";
        if(format[0]!=0){
            timeString+=" "+format[0]+" min";
        }
        if(format[1]!=0){
            timeString+=" "+format[1]+" sec";
        }
        if(format[2]!=0){
            timeString+=" "+format[2]+" ms";
        }
        return timeString;
    }
    private int duration(){
        return (int)(System.currentTimeMillis()-time);
    }

    private int[] toTime(){
        int durationTime=duration();
        int[] format=new int[3];
        format[2]=durationTime%1000;
        durationTime/=1000;
        format[1]=durationTime%60;
        durationTime/=60;
        format[0]=durationTime;
        return format;
    }
}
